///////////////////////////////////////////////////////
// Temporarily commented out until i can find a more suitable implementation.
///////////////////////////////////////////////////////


//using System;
//using System.Collections.Generic;
//using System.Text;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Input;
//using Microsoft.Xna.Framework.Graphics;
//using Microsoft.Xna.Framework.Content;
//using CreamXEngine.Game;

//namespace CreamXEngine.Components.GameComponents
//{
//    /// <summary>
//    /// The CreamX Mouse Object
//    /// </summary>
//    /// <remarks>Think of a better name.</remarks>
//    public class UniversalMouse : DrawableGameComponent
//    {
//#if(!XBOX360)
//        private MouseState _lastMouseState, _currentMouseState;
//#endif
//        private GamePadState _lastpadState, _currentPadState;
//        private PlayerIndex _padIndex;
//        private Vector2 _position;
        
//        public Vector2 Position
//        {
//            get { return _position; }
//            set { _position = value; }
//        }

//        private Texture2D _cursorTex;
//        public static Texture2D DefaultCursorTex;
//        private Color _cursorColor;
//        private SpriteBatch _spriteBatch;
//        private int _mouseSpeed = 25;
//        private int _mouseSpeedSlow = 10;
//        private ButtonState _leftButton;
//        private ButtonState _rightButton;
        
//        public Color Color
//        {
//            get { return _cursorColor; }
//            set { _cursorColor = value; }
//        }
//        public UniversalMouse(CreamXGame game)
//            : base(game)
//        {
//            this.DrawOrder = 10;
//            //Default the gamepad to player 1, this can be changed
//            _padIndex = PlayerIndex.One;
//            _cursorColor = Color.White;
//        }

//        public override void Update(GameTime gameTime)
//        {
//            UpdatePointer(GamePad.GetState(_padIndex));

//            base.Update(gameTime);
//        }

//        public override void Draw(GameTime gameTime)
//        {
//            //this._spriteBatch.Begin(SpriteBlendMode.AlphaBlend,SpriteSortMode.BackToFront,SaveStateMode.SaveState);
//            //this._spriteBatch.Draw(this._cursorTex, this._position, null,this._cursorColor,0f,GetOrigin(),Scale,SpriteEffects.None,0);
//            //this._spriteBatch.End();
//            base.Draw(gameTime);
//        }
//        public void Draw(GameTime gameTime,SpriteBatch batch)
//        {
//            //batch.Begin(SpriteBlendMode.AlphaBlend,SpriteSortMode.BackToFront,SaveStateMode.SaveState);
//            batch.Draw(this._cursorTex, this._position, null, this._cursorColor, 0f, GetOrigin(), Scale, SpriteEffects.None, 0);
//            //this._spriteBatch.End();
//            base.Draw(gameTime);
//        }
//        Vector2 _origin = Vector2.Zero;
//        public Vector2 GetOrigin()
//        {
//            return _origin;
//            //return new Vector2(PointerTexture.Width / 2, PointerTexture.Height / 2);
//        }
//        protected override void LoadContent()
//        {
            
//                //Load our own resources
//                ContentManager content = new ContentManager(Game.Services);
//                PointerTexture = content.Load<Texture2D>(@"Content\Textures\Cursor");
//                this._spriteBatch = new SpriteBatch(this.GraphicsDevice);
//                DefaultCursorTex = PointerTexture;
            
//            base.LoadContent();

//        }

//        #region Public Properties
//        public ButtonState LeftButton
//        {
//            get { return _leftButton; }
//            set { _leftButton = value; }
//        }
        
//        public ButtonState RightButton
//        {
//            get { return _rightButton; }
//            set { _rightButton = value; }
//        }

//        public Texture2D PointerTexture
//        {
//            get { return _cursorTex; }
//            set { _cursorTex = value; }
//        }

//        private float _scale=1f;

//        public float Scale
//        {
//            get { return _scale; }
//            set { _scale = value; }
//        }

//        public Color PointerColor
//        {
//            get { return _cursorColor; }
//            set { _cursorColor = value; }
//        }

//        public PlayerIndex PadIndex
//        {
//            get { return _padIndex; }
//            set { _padIndex = value; }
//        }

//        private bool _physicalMouseEnabled=true;

//        public bool PhysicalMouseEnabled
//        {
//            get { return _physicalMouseEnabled; }
//            set { _physicalMouseEnabled = value; }
//        }

//        public void UpdatePointer(GamePadState gamePadState)
//        {

//            int speed = _mouseSpeed;
//            if (_currentPadState != null)
//                _lastpadState = _currentPadState;

//            _currentPadState = gamePadState;
//            if (_currentPadState != _lastpadState)
//            {
//                if (gamePadState.Triggers.Right > 0)
//                    speed = _mouseSpeedSlow;

//                this._position.X = this._position.X + (gamePadState.ThumbSticks.Left.X * speed);
//                this._position.Y = this._position.Y + (-gamePadState.ThumbSticks.Left.Y * speed);

//                if (_currentPadState.ThumbSticks.Left.X != _lastpadState.ThumbSticks.Left.X || _currentPadState.ThumbSticks.Left.Y != _lastpadState.ThumbSticks.Left.Y)
//                    if (MouseMove != null) MouseMove(_position);

//                LeftButton = gamePadState.Buttons.A;
//                RightButton = gamePadState.Buttons.B;
//                Console.WriteLine(speed.ToString());
                
//            }
//            if (_physicalMouseEnabled)
//            {
//                #region Physical Mouse (Not for 360)

//#if(!XBOX360)
//                //Check if mouse is inside our window
//                if (_currentMouseState != null)
//                    _lastMouseState = _currentMouseState;

//                _currentMouseState = Mouse.GetState();
//                if (_currentMouseState != _lastMouseState)
//                {
//                    int w, h;
//                    w = GraphicsDevice.Viewport.Width;
//                    h = GraphicsDevice.Viewport.Height;
//                    if (_currentMouseState.X > 0 && _currentMouseState.Y > 0 && _currentMouseState.X < w && _currentMouseState.Y < h)
//                    {
//                        this._position.X = _currentMouseState.X;
//                        this._position.Y = _currentMouseState.Y;
//                        LeftButton = _currentMouseState.LeftButton;
//                        RightButton = _currentMouseState.RightButton;
//                        if (_currentMouseState.X != _lastMouseState.X || _currentMouseState.Y != _lastMouseState.Y)
//                            if (MouseMove != null) MouseMove(_position);

//                        if (_currentMouseState.LeftButton == ButtonState.Pressed && _lastMouseState.LeftButton != ButtonState.Pressed)
//                        {
//                            FireMouseDown(MouseButtons.Left);
//                        }
//                        if (_currentMouseState.RightButton == ButtonState.Pressed && _lastMouseState.RightButton != ButtonState.Pressed)
//                        {
//                            FireMouseDown(MouseButtons.Right);
//                        }
//                        if (_currentMouseState.LeftButton != ButtonState.Pressed && _lastMouseState.LeftButton == ButtonState.Pressed)
//                        {
//                            FireMouseUp(MouseButtons.Left);
//                        }
//                        if (_currentMouseState.RightButton != ButtonState.Pressed && _lastMouseState.RightButton == ButtonState.Pressed)
//                        {
//                            FireMouseUp(MouseButtons.Right);
//                        }
//                    }

//                }
//#endif
//                #endregion
//            }
//        }
        
//        public Vector2 Origin
//        {
//            get { return _origin; }
//            set { _origin = value; }
//        }

//        #endregion

//        #region Private Methods
//        private void FireClick(MouseButtons button)
//        {
//            if (MouseClick != null)
//                MouseClick(_position, button);
//        }

//        private void FireMouseDown(MouseButtons button)
//        {
//            if (MouseDown!= null)
//                MouseDown(_position, button);
//        }

//        private void FireMouseUp(MouseButtons button)
//        {
//            if (MouseUp!= null)
//                MouseUp(_position, button);
//            FireClick(button);
//        }
//        #endregion

//        #region Events
//        public event MouseEventHandler MouseClick;
//        public event MouseEventHandler MouseDown;
//        public event MouseEventHandler MouseUp;
//        public event MouseMoveEventHandler MouseMove;
//        #endregion

//    }
    
//    public delegate void MouseEventHandler(Vector2 position,MouseButtons mousebutton);
//    public delegate void MouseMoveEventHandler(Vector2 position);
    
//    public enum MouseButtons
//    {
//        Left,
//        Right,
//        Middle
//    }
//}
